
<template>
 <div>
<el-dialog
  title="预览文章"
  :visible.sync="dialogVisible"
  width="30%">
    <el-row class="el_row1">
        <el-col :span="24"><sapn>{{render.title}}</sapn> </el-col>
      </el-row>
        <el-row class="el_row2">
        <el-col :span="5"><span>{{render.createTime}}</span> </el-col>
        <el-col :span="3"><span>{{render.username}}</span></el-col>
        <el-col :span="2"><i class="el-icon-view"></i> <span>{{render.visits}}</span></el-col>
    </el-row>
      <el-row class="el_row3" >
      <el-col :span="24"><span>{{render.articleBody}}</span> </el-col>
    </el-row>
  <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>
 </div>
</template>

<script>
import { detail } from '@/api/hmmm/articles.js'
import { parseTime } from '@/utils/index.js'
export default {
  name: 'articlesPrev',
  props: {
  },
  data () {
    return {
      dialogVisible: false,
      render: {}
    }
  },
  methods: {
    openDialog () {
      this.dialogVisible = true
    },
    closeDialog () {
      this.dialogVisible = false
    },
    async getRenderForm (id, name) {
      const { data } = await detail({ id })
      this.render = { ...data }
      this.render.username = name
      this.render.articleBody = this.render.articleBody.replace(/<.*?>/ig, '')
      this.render.createTime = parseTime(this.render.createTime)
      this.openDialog()
    }
  }

}
</script>

<style scoped lang='less'>
.el_row1{
  font-size: 18px;
  font-weight: 600;
}
.el_row2{
  padding:20px 0 ;
  border-bottom: 1px dashed #333;
}
.el_row3{
  padding:20px 0 ;
  padding-left: 5px;
  background-color: #f5f5f5;
}
.dialog-footer{
  display: flex;
  justify-content: end;
}
</style>
